package com.ljfiction.book.adapter;

import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ljfiction.book.Baner.BookCommentBean;
import com.ljfiction.book.R;
import com.ljfiction.book.tools.ScreenUtils;
import com.ljfiction.book.tools.TimeTool;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.List;

/**
 * Created by Android on 2017/10/30.
 */

public class BookShupingAdapter extends BaseQuickAdapter<BookCommentBean.DataBean.ListBean,BaseViewHolder>{
    public BookShupingAdapter(@LayoutRes int layoutResId, @Nullable List<BookCommentBean.DataBean.ListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BookCommentBean.DataBean.ListBean item) {
        AutoUtils.autoSize(helper.itemView);
        helper.setText(R.id.content_usershuping,item.getCommentContext())
                .setText(R.id.usershuping_myname,item.getPseudonym())
                .setText(R.id.usershupingbookname,"《"+item.getBookName()+"》")
                .setText(R.id.usershupingtime, TimeTool.getTimeAndChange(String.valueOf(item.getCommentDateTime())))
                .setText(R.id.userselectnum,String.valueOf(item.getThumbsCount()))
                .setText(R.id.shupingdengliuser,"LV"+item.getUserGrade())
                .setText(R.id.userpinglunnum,String.valueOf(item.getReplyCount()));
        Glide.with(mContext).load(item.getUserHeadPortraitURL()).into((ImageView) helper.getView(R.id.usershuping_muimage));
        if (item.getUserSex()==0){
            ((ImageView) helper.getView(R.id.usershupingsex)).setImageResource(R.mipmap.sex_n);
        }else {
            ((ImageView) helper.getView(R.id.usershupingsex)).setImageResource(R.mipmap.sex_v);
        }
        if (item.getVipGrade()>0){
            helper.getView(R.id.isvipimage_usershuping).setVisibility(View.VISIBLE);
        }else {
            helper.getView(R.id.isvipimage_usershuping).setVisibility(View.GONE);
        }
        if (item.getIsthumbs() == 1) {
            ((ImageView) helper.getView(R.id.userdianzanimage)).setImageResource(R.mipmap.good);
        } else {
            ((ImageView) helper.getView(R.id.userdianzanimage)).setImageResource(R.mipmap.goodno);
        }
        helper.addOnClickListener(R.id.userdianzanimage);
        helper.addOnClickListener(R.id.usershuping_muimage);
    }

}
